# CMake最低版本要求
cmake_minimum_required(VERSION 3.10)

# 项目名称
project(matiec)
# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 设置通用的编译选项
set(COMMON_CXX_FLAGS "-g")
set(COMMON_CXX_WARNINGS "-Wall" "-Wpointer-arith" "-Wwrite-strings" "-Wno-unused")

include_directories(${PROJECT_SOURCE_DIR})

# 添加需要包含的子目录
add_subdirectory(absyntax)
add_subdirectory(absyntax_utils)
add_subdirectory(stage1_2)
add_subdirectory(stage3)
add_subdirectory(stage4)

# 定义可执行文件的源文件
set(SOURCES main.cc)

# 创建 'iec2c' 可执行文件并链接所需的库
add_executable(iec2c ${SOURCES})
target_link_libraries(iec2c
        stage1_2
        stage3
        stage4_generate_c
        absyntax
        absyntax_utils
)
# 添加编译选项到可执行文件
target_compile_options(iec2c PRIVATE ${COMMON_CXX_FLAGS} ${COMMON_CXX_WARNINGS})

# 创建 'iec2iec' 可执行文件并链接所需的库
add_executable(iec2iec ${SOURCES})
target_link_libraries(iec2iec
        stage1_2
        stage3
        stage4_generate_iec
        absyntax
        absyntax_utils
)

# 添加编译选项到可执行文件
target_compile_options(iec2iec PRIVATE ${COMMON_CXX_FLAGS} ${COMMON_CXX_WARNINGS})
